package com.five.welcome.controller;

import com.five.welcome.entity.Orders;
import com.five.welcome.result.Result;
import com.five.welcome.service.OrdersService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author ywt
 * @since 2024-07-12
 */
@RestController
@CrossOrigin
@Tag(name = "订单信息接口")
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private OrdersService ordersService;

    //根据学号查询订单
    @Operation(summary = "根据学号查询订单")
    @GetMapping("/getOrderBySNumber")
    public Result getOrderBySNumber(String sNumber) {
        Orders order = ordersService.getOrderBySNumber(sNumber);
        return Result.ok(order);
    }

    //根据订单号查询订单
    @Operation(summary = "根据订单号查询订单")
    @GetMapping("/getOrderByOrderId")
    public Result getOrderByOrderId(String orderId) {
        Orders order = ordersService.getOrderByOrderId(orderId);
        return Result.ok(order);
    }

    /**
     * 查询所有
     */
    @Operation(summary = "查询所有")
    @GetMapping("/selectAll")
    public Result selectAll(Orders orders) {
        List<Orders> list = ordersService.selectAll(orders);
        return Result.ok(list);
    }

}

